<?php

namespace app\controller;

use app\BaseController;
use app\model\ActivityGoods;
use think\facade\Request;

class ZsApi extends BaseController
{
    public function GoodsApplyRecord()
    {
        $headers = [
            'Access-Control-Allow-Origin' => '*',
            'Access-Control-Allow-Methods' => 'POST, GET, OPTIONS, PUT, DELETE',
            'Access-Control-Allow-Headers' => 'x-requested-with,content-type'
        ];
        $productId = Request::post('product_id');
        if(!$productId){
            return response(['code'=>-1,'msg'=>'缺少product_id参数'],200,$headers,'json');
        }
        $applyRecords = ActivityGoods::with(['activity'=>function($query){
            $query->field('buyin_activity_id,activity_name,apply_start_time,apply_end_time,promote_start_time,promote_end_time,online');
        }])->where(['product_id'=>$productId,'status'=>1,'goods_type'=>1])
            ->whereIn('audit_status',[0,1])
            ->field('buyin_activity_id,audit_status')
            ->select();
        return response(['code'=>1,'msg'=>'success','data'=>$applyRecords],200,$headers,'json');
    }

}